#!/bin/sh

[ -d m4 ] || mkdir m4

ACLOCAL=${ACLOCAL:-aclocal}
AUTOMAKE=${AUTOMAKE:-automake}
AUTOCONF=${AUTOCONF:-autoconf}

MODULES="qucs-core qucs qucs-doc"
ACLOCAL_FLAGS=-Im4

echo "Running $ACLOCAL..."
$ACLOCAL $ACLOCAL_FLAGS || exit 1

echo "Running $AUTOMAKE..."
$AUTOMAKE -a -c --gnu --add-missing  || exit 1

echo "Running $AUTOCONF..."
$AUTOCONF || exit 1

if test "x$1" = xhere; then
	exit 0;
fi

for i in $MODULES; do
	( cd $i;
	  echo bootstrapping $( pwd )
	  ./bootstrap || ( echo trouble in $i/bootstrap; exit 1 )
	) || exit 1
done
